package com.example;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;

import java.io.IOException;
@WebServlet("/b")
public class ServletB extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Cookie[] cookies = req.getCookies();
        for (Cookie cookie : cookies) {
            String cookie_key = cookie.getName();
            String cookie_Value = cookie.getValue();
            System.out.println("Key:\t" + cookie_key + "\tvalue:\t" + cookie_Value);
            HttpSession session=req.getSession();
            Integer math_value_session =(Integer) session.getAttribute("math");
            Integer math_value_request =(Integer) req.getAttribute("math");

            System.out.println("从session中取出的math的值:"+session.getAttribute("math"));
            System.out.println("从request中取出的math的值:"+req.getAttribute("math"));
        }
    }
}